package com.reminder;

import com.reminder.shared.ReminderRequestFactory;
import com.reminder.shared.ReminderRequest;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class SendInvite extends Activity {
    /** Called when the activity is first created. */
	private EditText email;
	private TextView textEmail;
	private String sendEmail;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.create_user_group);
    }
    
    public void onAddInvite(View view) {
    	email = (EditText) findViewById(R.id.send_email);
    	sendEmail = email.getText().toString();
    	onAcceptClick();
    	email.setText("");
    	Toast.makeText(this,"you sent the invitation to the user " + sendEmail, Toast.LENGTH_SHORT).show();		  
    	
    }
    
    public void onAcceptClick() {
    	new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... arg0) {
    	ReminderRequestFactory factory = (ReminderRequestFactory) Util
                .getRequestFactory(SendInvite.this,
                        ReminderRequestFactory.class);
        ReminderRequest request = factory.taskRequest();
        request.createUserGroup(sendEmail).fire();
        return null;
            }

        }.execute();
   }
}